<template>
    <div>
        <van-field v-model="name" label="名称" placeholder="请输入用户名" id='name' />
        <van-button @click='update' id='add'>修改</van-button>
    </div>
</template>

<script>
    export default {
        data(){
            return{
                id:this.$route.query.id,
                name:''
            }
        },
        methods:{
            update(){
                this.$axios.post('cateM',{'name':this.name,'id':this.id}).then(res=>{
                    if(res.data.code==200){
                        alert('修改成功')
                        this.$router.push('showcate')
                    }
                })
            },
            get_cate(){
                this.$axios.get('getcateByid?id='+this.id).then(res=>{
                    this.name = res.data.cate.name
                })
            }
        },
        mounted(){
            this.get_cate()
        }
    }
</script>

<style scoped>

</style>